<p>结构指令</p>
<p> flag: {{flag}}</p>
<p *ngIf=" flag ">ngif操作</p>
<input type="button" value="切换flag" (click)=" flag=!flag ">
<p *ngIf=" num ">ngif操作取值num</p>
<input type="button" value="+" (click)=" num=num+1 ">
<input type="button" value="-" (click)=" num=num-1 ">

<p *ngIf=" [] ">ngif操作取值Arr</p>
<p *ngIf=" user ">ngif操作取值Obj</p>
<p> {{JSON.stringify(user)}} </p>
<p *ngIf="JSON.stringify(user)=='{}'">user为空</p>
<input type="button" value="user置空" (click)="user={}">

<h1>ngSwitch</h1>

<input type="button" value="name='tom'" (click)=" name='tom' ">
<input type="button" value="name='jack'" (click)=" name='jack'">
<input type="button" value="name='随机值'" (click)=" name='asdas' ">

<ul [ngSwitch]="name">
    <li *ngSwitchCase=" 'tom' ">tom</li>
    <li *ngSwitchCase=" 'jack' ">jack</li>
    <li *ngSwitchDefault>unknown</li>
</ul>

<h1>ngFor</h1>
<p>names: {{names}} </p>
<ul>
    <li *ngFor="let name of names;let i = index"> {{name}}:{{i}} </li>
</ul>
<!-- <ul>
    <li *ngFor="let k of obj"> {{k}} </li>
</ul> -->
<ul>
    <li *ngFor="let k of getKeys(obj);"> {{k}}:{{obj[k]}} </li>
</ul>

<p> {{ getKeys(obj) }} </p>

<ul>
    <li *ngFor=" 
    let name of names;
    let i = index;
    let f = first;
    let l = last;
    let e = even;
    let o = odd; 
     ">
        {{name}}：{{i}}：{{f}}:{{l}}:{{e}}:{{o}}
    </li>
</ul>